package com.cskaoyan.controller.configmanagement;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.PageDataVo;
import com.cskaoyan.bean.configmanagement.Express;
import com.cskaoyan.bean.configmanagement.MallVO;
import com.cskaoyan.bean.configmanagement.Order;
import com.cskaoyan.bean.configmanagement.WX;
import com.cskaoyan.service.configmanagement.ConfigManagementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.lang.reflect.Field;

@RestController
@RequestMapping("admin/config")
public class ConfigManagementController {
    @Autowired
    ConfigManagementService configManagementService;
    @GetMapping("mall")
    public BaseRespVo mallConfigEcho() throws IllegalAccessException {
        MallVO mallVO = configManagementService.mallEcho();
        return BaseRespVo.ok(mallVO);
    }
    @PostMapping("mall")
    public BaseRespVo mallConfigModify(@RequestBody MallVO mallVO) throws IllegalAccessException {
        configManagementService.mallModify(mallVO);
        return BaseRespVo.ok();
    }
    @GetMapping("express")
    public BaseRespVo expressEcho() throws IllegalAccessException {
        Express express = configManagementService.expressEcho();
        return BaseRespVo.ok(express);
    }
    @PostMapping("express")
    public BaseRespVo expressModify(@RequestBody Express express) throws IllegalAccessException {
        configManagementService.expressModify(express);
        return BaseRespVo.ok();
    }
    @GetMapping("order")
    public BaseRespVo orderEcho() throws IllegalAccessException {
        return BaseRespVo.ok(configManagementService.orderEcho());
    }
    @PostMapping("order")
    public BaseRespVo orderModify(@RequestBody Order order) throws IllegalAccessException {
        configManagementService.orderModify(order);
        return  BaseRespVo.ok();
    }
    @GetMapping("wx")
    public BaseRespVo WXEcho() throws IllegalAccessException {
        return BaseRespVo.ok(configManagementService.WXEcho());
    }
    @PostMapping("wx")
    public BaseRespVo WXModify(@RequestBody WX wx) throws IllegalAccessException {
        configManagementService.WXModify(wx);
        return BaseRespVo.ok();
    }
}
